/**
 * Copyright 2022 Stars embedded, All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * @FilePath: /FA/SmartCentControl/entry/src/main/js/default/pages/index/index.js
 * @Description:
 * @Author: lin zhang
 * @Date: 2022-03-04 18:55:47
 * @LastEditTime: 2022-03-15 15:35:18
 * @LastEditors: lin zhang
 * 变更历史:
 */

import app from '@system.app'

export default {
    data: {
        index : 0,
        temperature:26.5,
        humidity:78,
        device_all:10,
        device_online:8,
    },

    setTimeOut() {

        var timeoutID = setTimeout(function() {
        }, 1000);
    },
    getDht11()
    {
        let that = this

        app.getDht11data(
            {
                code : 0,
                success(res)
                {
                    that.temperature = res.temperature;
                    that.humidity = res.humidity
                },
                fail(res,code){

                },
                complete(){

                }
            }
        )
    },

    setInterval() {
        let that = this;
        var intervalID = setInterval(function() {
          //  that.getDht11();
        }, 2000);
    },

    onInit(){
        this.index = 0;
        this.setTimeOut();
        this.setInterval();
    },


    change(e)
    {
       this.index = e.index;
    },
    select(e)
    {
        if(e == this.index)
        {
            return true;
        }else
        {
            return false;
        }
    },

    exit(e)
    {
        app.terminate();
    },

    open(e){
        let that = this
        console.log("Open")
        app.mqttpublish({
            code:1,
            success(res){

            },
            fail(res,code){

            },
            complete(){

            }
        })
    },

}
